using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using Praxis.Entities;

namespace Praxis.Repository.Mapping
{
    public class PAGOMap : EntityTypeConfiguration<PAGO>
    {
        public PAGOMap()
        {
            // Primary Key
            this.HasKey(t => t.Codigo);

            // Properties
            this.Property(t => t.Contacto)
                .IsRequired()
                .HasMaxLength(200);

            this.Property(t => t.NumComprobante)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("PAGO");
            this.Property(t => t.Codigo).HasColumnName("Codigo");
            this.Property(t => t.Contacto).HasColumnName("Contacto");
            this.Property(t => t.FechaPago).HasColumnName("FechaPago");
            this.Property(t => t.Abono).HasColumnName("Abono");
            this.Property(t => t.NumComprobante).HasColumnName("NumComprobante");

            // Relationships
            this.HasOptional(t => t.COMPROBANTE)
                .WithMany(t => t.PAGOes)
                .HasForeignKey(d => d.NumComprobante);

        }
    }
}
